Skip to content

feat: Add copy json config button #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

sumeetpardeshi
Copy link

Added a copy config button, to copy the json config for the server currently being tested.

Motivation and Context

Currently when we are adding configs to mcp.json configuration for any client(eg. cursor), we need to manually copy the command, args and env variable. Idea is to improve UX and provide a quick copy button, which when clicked will have the config ready in clipboard to be pasted in mcp.json file. we also show a toast when the values are copied to clipboard.
 Environment Variables
image

this config will be copied to clipboard when testing uvx mcp-server-fetch
{ "command": "uvx", "args": [ "mcp-server-fetch" ], "env": { "YOUR_ENV_VARIABLES": "VALUE" } }

so the Idea is in an existing mcp.json file, you will add this server config from clipboard as below:

{ "mcpServers": { "your-server-name": <paste-copied-config-here> } }

How Has This Been Tested?

Tested locally by connecting to a mcp-server-fetch server
image

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Copy link
Member

@olaservo olaservo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, I like the idea of making this more convenient. I think we should make some of this more generic though, rather than assuming we can use the Cursor format.

Another thing to take a look at is the recent support added for using a config file with inspector, mentioned here under the table: https://github.com/modelcontextprotocol/inspector?tab=readme-ov-file#configuration

I'm thinking that another way to avoid the UI edit -> partial config copy/paste process might be to edit a config file instead, and then just refer to that same config for your client and Inspector?

@cliffhall
Copy link
Contributor

cliffhall commented May 1, 2025

Thanks for the PR, I like the idea of making this more convenient. I think we should make some of this more generic though, rather than assuming we can use the Cursor format.

Another thing to take a look at is the recent support added for using a config file with inspector, mentioned here under the table: https://github.com/modelcontextprotocol/inspector?tab=readme-ov-file#configuration

I think the format that's listed above matches our config file format:

Suggestion

Screenshot 2025-05-01 at 4 09 21 PM

Our format

Screenshot 2025-05-01 at 4 09 39 PM

I'm thinking that another way to avoid the UI edit -> partial config copy/paste process might be to edit a config file instead, and then just refer to that same config for your client and Inspector?

That seems like a good plan, but I'm sure the copy and paste could still be useful.

Maybe, since this gaping hole exists in the UI...

Screenshot 2025-05-01 at 4 17 23 PM

... we could put two buttons: Copy Config File and Copy Config Entry

  • Copy Config File would copy a whole config file shape with just the currently connected server in it,
  • Copy Config Entry would give you an entry for such a file.

@cliffhall cliffhall added enhancement New feature or request waiting on submitter Waiting for the submitter to provide more info labels May 1, 2025
@sumeetpardeshi
Copy link
Author

@cliffhall thanks for the inputs here, appreciate the help. I too validated that most clients have same format for mcp.json , so @olaservo your query should also be resolved with that.

I will go ahead and add those 2 buttons and update the PR.

@sumeetpardeshi
Copy link
Author

sumeetpardeshi commented May 1, 2025

image

Added 2 buttons:

  • Config Entry
  • Config File

Note: Ignored the Copy Prefix suggested above as its causing UI to overflow when both buttons on same line. to compensate added appropriate icons and tooltips for clear understanding though.

@sumeetpardeshi sumeetpardeshi requested a review from olaservo May 1, 2025 22:47
@cliffhall
Copy link
Contributor

@sumeetpardeshi Can we make the buttons take up the whole space?

@sumeetpardeshi
Copy link
Author

@cliffhall, now buttons take up the whole space.
image

Copy link
Contributor

@cliffhall cliffhall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sumeetpardeshi Looking good. A couple things, though.

Changes

  • Add tests in Sidebar.test.tsx
  • Add some explanation of this functionality in README.md.

Are we sure 'Config' is the right name here?

Since we have a Configuration button just below these new buttons, one might think that it would copy all of those values as well, but it does not. That's because the mcp.json files used by other clients, and our own configuration settings are two separate things. We have to disambiguate.

The easiest way to do that would be to rename these buttons.

Server Entry & Servers File perhaps?

@sumeetpardeshi
Copy link
Author

@cliffhall I agree with your point of calling it Server Entry & Servers File to avoid confusion.
next steps:

  • Change references and button names as suggested.
  • add test cases for this feature
  • The image(mcp-inspector.png) also needs to update to include these new buttons in sidebar.

@cliffhall
Copy link
Contributor

cliffhall commented May 5, 2025

@cliffhall I agree with your point of calling it Server Entry & Servers File to avoid confusion. next steps:

  • Change references and button names as suggested.
  • add test cases for this feature
  • The image(mcp-inspector.png) also needs to update to include these new buttons in sidebar.

And a section of the README that explains what these buttons do and what the copied data is for.

- change button names
- adding unit test cases
- updated landing page image
- updating README file
as discussed here: modelcontextprotocol#334 (comment)
@sumeetpardeshi sumeetpardeshi requested a review from cliffhall May 6, 2025 00:32
Copy link
Contributor

@cliffhall cliffhall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few requests...

README.md Outdated
@@ -42,6 +42,74 @@ CLIENT_PORT=8080 SERVER_PORT=9000 npx @modelcontextprotocol/inspector node build

For more details on ways to use the inspector, see the [Inspector section of the MCP docs site](https://modelcontextprotocol.io/docs/tools/inspector). For help with debugging, see the [Debugging guide](https://modelcontextprotocol.io/docs/tools/debugging).

### Configuration Export
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be best to avoid the word Configuration here because, as with the button naming, we need to disambiguate "Configuration" vs "MCP Server File", since our app's configuration is not this configuration for other apps.

Suggested change
### Configuration Export
Servers File Export

README.md Outdated
@@ -42,6 +42,74 @@ CLIENT_PORT=8080 SERVER_PORT=9000 npx @modelcontextprotocol/inspector node build

For more details on ways to use the inspector, see the [Inspector section of the MCP docs site](https://modelcontextprotocol.io/docs/tools/inspector). For help with debugging, see the [Debugging guide](https://modelcontextprotocol.io/docs/tools/debugging).

### Configuration Export

The MCP Inspector provides convenient buttons to export your server configuration:
Copy link
Contributor

@cliffhall cliffhall May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The MCP Inspector provides convenient buttons to export your server configuration:
The MCP Inspector provides convenient buttons to export server launch configurations for use in clients such as Cursor, Claude Code, or the Inspector's CLI. The file us usually called `mcp.json`.

Copy link
Contributor

@cliffhall cliffhall May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want it to be clear that the Inspector UI itself isn't currently using mcp.json (though perhaps we should consider it).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inspector does support using a JSON file as of the update to add CLI mode, so we should align the wording and naming there so they don't diverge too much: https://github.com/modelcontextprotocol/inspector/blob/main/README.md#configuration

The inspector also supports configuration files to store settings for different MCP servers. This is useful when working with multiple servers or complex configurations:

npx @modelcontextprotocol/inspector --config path/to/config.json --server everything

Copy link
Contributor

@cliffhall cliffhall May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inspector does support using a JSON file as of the update to add CLI mode, so we should align the wording and naming there so they don't diverge too much: https://github.com/modelcontextprotocol/inspector/blob/main/README.md#configuration

The inspector also supports configuration files to store settings for different MCP servers. This is useful when working with multiple servers or complex configurations:

npx @modelcontextprotocol/inspector --config path/to/config.json --server everything

@olaservo I honestly haven't focused enough on the CLI. The file is the same format. We should consider using it on the UI as well. For now I updated the suggestion above to include the Inspector's CLI.

Copy link
Member

@olaservo olaservo May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, UI mode can use the config file too, you just need to pass the flag like I showed in this example: #349

README.md Outdated
@@ -93,6 +161,8 @@ Example server configuration file:
}
```

> **Tip:** You can easily generate this configuration format using the **Server Entry** and **Servers File** buttons in the Inspector UI, as described in the Configuration Export section above.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> **Tip:** You can easily generate this configuration format using the **Server Entry** and **Servers File** buttons in the Inspector UI, as described in the Configuration Export section above.
> **Tip:** You can easily generate this configuration format using the **Server Entry** and **Servers File** buttons in the Inspector UI, as described in the Servers File Export section above.

setCopiedServerFile(false);
}, 2000);
})
.catch((error) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this catch necessary? It does the same thing as the catch for the surrounding try block.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cliffhall idea was:

  • The outer catch handles synchronous errors
  • The inner catch handles asynchronous Promise rejections
    if we only keep the outer catch, promise rejection from clipboard activity might not be caught in external synchronous catch. one option can be to covert inner cliboard call into await style sync and then have only single catch.
    let me know what you think on this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you merge main into your branch and take this screenshot again? Also, from the docs above, I gather it wasn't tested with streamableHttp, only stdio and sse. Those should be updated as well.

@sumeetpardeshi
Copy link
Author

@cliffhall I've addressed all the suggestions mentioned above

@sumeetpardeshi sumeetpardeshi requested a review from cliffhall May 6, 2025 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request waiting on submitter Waiting for the submitter to provide more info
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants